package com.zbkj.admin.controller.mszs;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.request.mszs.MszsYwRecordRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.mszs.MszsYwRecordResponse;
import com.zbkj.service.service.mszs.MszsYwRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 民宿助手-业务记录
 * JIANTAO
 */

@Slf4j
@RestController
@RequestMapping("api/admin/mszs/yw")
@Api(tags = "民宿助手-业务记录")
@Validated
public class MszsYwRecordController {

    @Resource
    private MszsYwRecordService recordService;

    @PreAuthorize("hasAuthority('admin:mszs:YwRecord:insert')")
    @ApiOperation(value="新增-业务记录")
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public CommonResult<Boolean> insert(@RequestBody @Validated MszsYwRecordRequest request){
        return CommonResult.success(recordService.insert(request));
    }

    @PreAuthorize("hasAuthority('admin:mszs:YwRecord:delete')")
    @ApiOperation(value="刪除-根据id标识删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<Boolean> del(@RequestParam("id")Integer id){
        return CommonResult.success(recordService.delete(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:YwRecord:load')")
    @ApiOperation(value="查询-根据主键id查询")
    @RequestMapping(value = "/load", method = RequestMethod.GET)
    @ApiImplicitParam(name = "id", value = "主键id标识",required = true)
    public CommonResult<MszsYwRecordResponse> load(@RequestParam("id") Integer id) {
        return CommonResult.success(recordService.load(id));
    }

    @PreAuthorize("hasAuthority('admin:mszs:YwRecord:pageList')")
    @ApiOperation(value="查询-分页查询")
    @RequestMapping(value = "/pageList", method = RequestMethod.GET)
    public CommonResult<CommonPage<MszsYwRecordResponse>> pageList(
            @Validated String title,
            @Validated PageParamRequest pageParamRequest) {
        CommonPage<MszsYwRecordResponse> mszsOrderPage = CommonPage.restPage(recordService.pageList(title,pageParamRequest));
        return CommonResult.success(mszsOrderPage);
    }


}
